package com.evan.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @description:
 * @author: xiaohu
 * @createDate: 2021/7/20 22:50
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket createDoc(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.evan.common.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("Swagger2 Controller 接口")
                .description("Swagger2 Common Controller 接口")
                .version("v1.0")
                .contact(new Contact(
                        "xiaohu",
                        "个人链接：https://blog.csdn.net/weixin_40657218?spm=1001.2101.3001.5343",
                        "邮箱：xiaohu.feng@hotmail.com"))
                .build();
    }
}
